import request from '@/utils/http'

// 获取用户列表
export function fetchGetUserList(params: any) {
  return request.get({
    url: '/auth.admin/list',
    params
  })
}

// 获取角色列表
export function fetchGetRoleList(data: any) {
  return request.get({
    url: '/auth.role/list',
    data
  })
}

// 获取菜单列表
export function fetchGetMenuList() {
  return request.get({
    url: '/auth.menu/list'
  })
}

// 获取日志列表
export function fetchAdminLogList(params: any) {
  return request.get({
    url: '/auth.admin/log',
    params
  })
}
// 删除日志
export function deleteAdminLogApi(ids: number[]) {
  return request.post({
    url: '/auth.admin/logdel',
    data: { ids }
  })
}
export function deleteMenuApi(ids: number[]) {
  return request.post({
    url: '/common.upload/delete',
    data: { ids }
  })
}
export function editMenuApi(data: any) {
  return request.post({
    url: '/auth.menu/edit',
    data
  })
}
export function addMenuApi(data: any) {
  return request.post({
    url: '/auth.menu/add',
    data
  })
}

// 添加用户
export const addUserApi = (data: any) => {
  return request.post({
    url: '/auth.admin/add',
    data
  })
}
// 编辑用户
export const editUserApi = (data: any) => {
  return request.post({
    url: '/auth.admin/edit',
    data
  })
}
//删除管理员 支持批量删除
export function deleteUserApi(ids: number[]) {
  return request.post({
    url: '/auth.admin/del',
    data: { ids }
  })
}

// 添加角色
export const addRoleApi = (data: any) => {
  return request.post({
    url: '/auth.role/add',
    data
  })
}

// 编辑角色
export const editRoleApi = (data: any) => {
  return request.post({
    url: '/auth.role/edit',
    data
  })
}
// 删除角色 支持批量删除
export function deleteRoleApi(ids: number[]) {
  return request.post({
    url: '/auth.role/del',
    data: { ids }
  })
}

// 获取日志列表
export function fetchLogList(params: any) {
  return request.get({
    url: '/admin.adminlog',
    params
  })
}
// 删除日志
export function deleteLogApi(ids: number[]) {
  return request.post({
    url: '/admin.adminlog/del',
    data: { ids }
  })
}
